#!/usr/bin/python

from gui import GUI
from gui.panda import PandaPrimitive, PandaGameDialog

from gameset.phoenicia import *


def setup_debug_city(location):
    housing = location(11, 11).area_sized(10, 4)
    
    yield housing.fit_buildings(House)
    yield housing.grown_by(1).fit_buildings(Road)
    yield housing.top_left.in_direction(-1, -2).fit_building(Signpost)
    
    farm = housing.moved_up(4).moved_right(4).sized(3)
    
    yield farm.fit_buildings(Farm)
    yield farm.grown_by(3, 0).fit_buildings(CarrotField)
    yield farm.grown_by(3).fit_buildings(WheatField)
    yield farm.grown_by(4).fit_buildings(Road)
    
    clay = housing.moved_down(5).with_width(4)
    
    yield clay.fit_buildings(ClayPit)
    yield clay.grown_by(1).fit_buildings(Road)

    granary = clay.moved_right(6)
    
    yield granary.fit_buildings(Granary)
    yield granary.grown_by(1).fit_buildings(Road)
    
    market = housing.moved_left(3).sized(2, 2)
    
    yield market.fit_buildings(FoodSeller)
    yield market.grown_by(1).fit_buildings(Road)


def setup_debug_view(view):
    view.zoom_in(5)
    view.center_camera_on(14, 27)


def main():
    gui = GUI(title = 'Phoenicia', size = (1024, 768), primitive = PandaPrimitive(data_path = '../data', debug = True))
    gui.setup_primitive()
    
    scenario = Beirut()
    scenario.place_from(setup_debug_city)
    
    dialog = PandaGameDialog(scenario = scenario)
    gui.set_dialog(dialog)
    
    setup_debug_view(dialog.view)

    gui.run()


if __name__ == '__main__':
    main()
